<?php
/**
 * @author Eni
 * @version 0.1.1
 */
class Model_Client extends Pidguin_Db_Table_Abstract
{
	/**
	 * Table name
	 *
	 * @var string
	 */
	protected $_name = 'clients';
	
	protected $_referenceMap    = array();
	
	/**
	 * 
	 * @var object
	 */
	protected $_currentRow = null;
	
	/**
	 * Instance of class
	 *
	 * @var Model_Client
	 */
	private static $_instance = null;
	
	/**
	 * Get instance of class
	 *
	 * @return Model_Client
	 */
	public static function getInstance()
	{
		if (self::$_instance === null) {
			self::$_instance = new self();
		}
		return self::$_instance;
	}
		
	/**
	 * Get a string current session
	 * 
	 * @return Zend_Db_Table_Row|null
	 */
	public function getCurrentRow()
	{
		if ($this->_currentRow) {
			return $this->_currentRow;
		}
		$sid = Zend_Session::getId();
		$row = $this->fetchRow($this->select()->where($this->getAdapter()->quoteInto('sid = ?', $sid)));
		
		if ($row) {
			$this->_currentRow = $row;
			return $this->_currentRow;
		}
		
		return null;
	}
}